package com.itheima.utils;

import com.itheima.pojo.Dish;
import com.itheima.pojo.DishNew;
import com.itheima.pojo.Setmeal;
import com.itheima.pojo.SetmealNew;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author: 放学后海堤日记
 * @Date: 2023/4/14 15:05
 * @Desc: 用于dish实体类的数据转移
 */
@Slf4j
public class PojoDataExchange {
    public static DishNew dataExchange(Dish dish, String categoryName) {
//        log.info("========================开始数据转移==========================");
//        log.info(dish.toString());

        DishNew dishNew = new DishNew();

        dishNew.setId(dish.getId());
        dishNew.setName(dish.getName());
        dishNew.setCategoryId(dish.getCategoryId());
        dishNew.setPrice(dish.getPrice());
        dishNew.setCode(dish.getCode());
        dishNew.setImage(dish.getImage());
        dishNew.setDescription(dish.getDescription());
        dishNew.setStatus(dish.getStatus());
        dishNew.setSort(dish.getSort());
        dishNew.setCreateTime(dish.getCreateTime());
        dishNew.setUpdateTime(dish.getUpdateTime());
        dishNew.setCreateUser(dish.getCreateUser());
        dishNew.setUpdateUser(dish.getUpdateUser());
        dishNew.setCategoryName(categoryName);

//        log.info("======================数据转移=========================");
//        log.info(dishNew.toString());
        return dishNew;
    }

    public static Dish backExchange(DishNew dishNew) {
        Dish dish = new Dish();

        dish.setId(dishNew.getId());
        dish.setName(dishNew.getName());
        dish.setCategoryId(dishNew.getCategoryId());
        dish.setPrice(dishNew.getPrice());
        dish.setCode(dishNew.getCode());
        dish.setImage(dishNew.getImage());
        dish.setDescription(dishNew.getDescription());
        dish.setStatus(dishNew.getStatus());
        dish.setSort(dishNew.getSort());
        dish.setCreateTime(dishNew.getCreateTime());
        dish.setUpdateTime(dishNew.getUpdateTime());
        dish.setCreateUser(dishNew.getCreateUser());
        dish.setUpdateUser(dishNew.getUpdateUser());

        return dish;
    }

    public static SetmealNew dataExchange(Setmeal setmeal) {
        SetmealNew setmealNew = new SetmealNew();

        setmealNew.setId(setmeal.getId());
        setmealNew.setCategoryId(setmeal.getCategoryId());
        setmealNew.setName(setmeal.getName());
        setmealNew.setPrice(setmeal.getPrice());
        setmealNew.setStatus(setmeal.getStatus());
        setmealNew.setCode(setmeal.getCode());
        setmealNew.setDescription(setmeal.getDescription());
        setmealNew.setImage(setmeal.getImage());
        setmealNew.setCreateTime(setmeal.getCreateTime());
        setmealNew.setUpdateTime(setmeal.getUpdateTime());
        setmealNew.setCreateUser(setmeal.getCreateUser());
        setmealNew.setUpdateUser(setmeal.getUpdateUser());

        return setmealNew;
    }

    public static Setmeal backExchange(SetmealNew setmealNew) {
        Setmeal setmeal = new Setmeal();

        setmeal.setId(setmealNew.getId());
        setmeal.setCategoryId(setmealNew.getCategoryId());
        setmeal.setName(setmealNew.getName());
        setmeal.setPrice(setmealNew.getPrice());
        setmeal.setStatus(setmealNew.getStatus());
        setmeal.setCode(setmealNew.getCode());
        setmeal.setDescription(setmealNew.getDescription());
        setmeal.setImage(setmealNew.getImage());
        setmeal.setCreateTime(setmealNew.getCreateTime());
        setmeal.setUpdateTime(setmealNew.getUpdateTime());
        setmeal.setCreateUser(setmealNew.getCreateUser());
        setmeal.setUpdateUser(setmealNew.getUpdateUser());

        return setmeal;
    }
}
